package com.ssm.base.page;

import org.apache.ibatis.session.RowBounds;

/**
 * Created by Administrator on 2016/7/4.
 */
public class PageParam extends RowBounds {

    private int limit;
    private int pageNum;
    private int offset;

    public PageParam() {
    }

    public PageParam(int pageNum, int pageSize) {

        if(pageNum<=0){
            throw new IllegalArgumentException("pageNum must a positive number");
        }
        if(pageSize<=0){
            throw new IllegalArgumentException("pageSize must a positive number");
        }
        this.pageNum = pageNum;
        this.limit = pageSize;
        this.offset = (pageNum-1)*limit;

    }

    public int getPageNum() {
        return pageNum;
    }

    public void setPageNum(int pageNum) {
        this.pageNum = pageNum;
        this.offset = (pageNum-1)*limit;
    }

    public void setPageSize(int pageSize) {
        this.limit = limit;
        this.offset = (pageNum-1)*limit;
    }
    public int getPageSize() {
        return this.limit;
    }

    @Override
    public int getOffset() {
        return this.offset;
    }

    @Override
    public int getLimit() {
        return this.limit;
    }
}
